﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace BeatEmUp.Menu
{
    public class MenuScoresScreen : MenuScreen
    {
        private GameManager game;
        private SpriteFont font;

        public MenuScoresScreen(GameManager game) :
            base(game)
        {
            this.game = game;
            this.isTitleVisible = true;
        }

        public void LoadContent(ContentManager content)
        {
            LoadBaseContent(content);
            font = content.Load<SpriteFont>("Fonts/Player");
            
        }

        public void Draw(SpriteBatch sb, List<int> scoreList)
        {
            DrawBaseElements(sb);

            sb.DrawString(font, "High scores",
                new Microsoft.Xna.Framework.Vector2(game.graphics.PreferredBackBufferWidth / 2 - 90, 120),
                Color.DarkBlue);

            for (int i = 0; i <scoreList.Count; i++)
            {
                if ((180 + i * 40) < 460)
                {
                    sb.DrawString(font, scoreList[i].ToString(),
                        new Microsoft.Xna.Framework.Vector2(game.graphics.PreferredBackBufferWidth / 2 - 30, 180 + i * 40),
                        Color.Black);
                }
            }
        }

        public void Update(Microsoft.Xna.Framework.GameTime gameTime, MenuMainComponent menu)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.isVisibleAndActive = false;
                menu.mainScreen.isVisibleAndActive = true;
            }
        }
    }
}
